
const db = require('../db/index')

exports.addArticle = (req,res)=>{
    //
    const sql = `insert into ev_articles set ?`;
    let data = {
        ...req.body,
        pub_date: new Date(),
    }
    db.query(sql,data,(err,results)=>{
        if(err) return res.cc(err)
        if(results.affectedRows != 1) return res.cc('新增文章失败')

        res.cc('新增文章成功！',0)
    })
}

exports.selectArticle = (req,res) =>{
    const sql = `select * from ev_articles`
    db.query(sql,(err,results)=>{
        if(err) return res.cc(err)
        res.send({
            status:0,
            message:'查询成功',
            list:results
        })
    })
}
